package com.lzx.kafka.controller;

import com.lzx.kafka.producer.KfkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class KafkaTestController {

	@Autowired
	private KfkaProducer producer;

	/**
	 * 如果为0就抛异常,1就不抛异常,
	 * 张俊杰 2021年01月29日 13:12
	 */
	@GetMapping("/testSendMsg")
	@ResponseBody
	public String testSendMsg(String flag) {
		try {
			producer.send(flag);
		} catch (Exception e) {
			e.printStackTrace();
			return "false";
		}
		return "success";
	}

}
